package com.controller.hm;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import com.entity.Customer;
import com.entity.Solution;
import com.service.hm.SolutionService;

@Controller
public class SolutionController {
	@Autowired
	private SolutionService solutionService;
	
	/**
	 * 无条件分页查询
	 * @param pages
	 * @param size
	 * @return
	 */
	@GetMapping("/solution_list")
	@ResponseBody
	public Page<Solution> solution_list(Integer pages,Integer size){		
		return solutionService.queryNoCriteria(pages-1, size);
	}
	
//	@PostMapping("/solution_add")
//	@ResponseBody
//	public void solution_add(@RequestBody Solution s){		
//		
//	}
	
	/**
	 * 删除
	 * @param sid
	 */
	@DeleteMapping("/solution_delete")
	@ResponseBody
	public void solution_delete(Long sid){		
		try{
			solutionService.delete(sid);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	/**
	 * 主题查询
	 * @param theme
	 * @param pages
	 * @param size
	 * @return
	 */
	@GetMapping("/solution_queryByTheme")
	@ResponseBody
	public Page<Solution> solution_queryByTheme(String theme,Integer pages,Integer size){
		return solutionService.queryByTheme(theme,pages-1, size);
	}
	
	/**
	 * 加载前十条客户
	 * @return
	 */
	@GetMapping("/solution_queryTen")
	@ResponseBody
	public List<Customer> solution_queryTen(){
		return solutionService.queryTen();
	}
	

}
